package com.WJY.dao;

import com.WJY.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentDao {

    //查询所有学生
    @Select("select * from mx.student")
    List<Student> queryStudentList();

    //根据id查询学生
    @Select("select * from mx.student where stuId = #{id}")
    Student queryStudentById(@Param("id") int id);

    //根据姓名进行模糊查询
    @Select("select * from mx.student where stuName like '%${name}%'")
    List<Student> queryStudentByName(@Param("name") String name);

    //根据id删除学生
    @Delete("delete from mx.student where stuId = #{id}")
    int delStudentById(@Param("id") int id);

    //新增学生
    @Insert("insert into mx.student (stuId, stuName, stuSex, stuAge) values (#{stuId},#{stuName},#{stuSex},#{stuAge})")
    int addStudent(Student student);

    //更新学生
    @Update("update mx.student set stuName = #{stuName},stuSex = #{stuSex},stuAge = #{stuAge} where stuId = #{stuId}")
    int updateStudent(Student student);

}
